<!-- include tpl=head_lay -->
<script type="text/javascript">
function collection_edit(fid)
{
	var url = '{url ctrl=plugin func=exec id=collection exec=field_set/}&fid='+fid;
	$.dialog.open(url,{
		'title':'编辑字段',
		'width':'700px',
		'height':'550px',
		'lock':true,
		'ok':function(){
			var iframe = this.iframe.contentWindow;
			if (!iframe.document.body) {
				alert('iframe还没加载完毕呢');
				return false;
			};
			iframe.save();
			return false;
		},
		'okVal':'提交修改',
		'cancelVal':'取消',
		'cancel':function(){
			return true;
		}
	});
}
function collection_add()
{
	var url = '{url ctrl=plugin func=exec id=collection exec=field_set tid=$rs.id/}';
	$.dialog.open(url,{
		'title':'添加字段',
		'width':'700px',
		'height':'550px',
		'lock':true,
		'ok':function(){
			var iframe = this.iframe.contentWindow;
			if (!iframe.document.body) {
				alert('iframe还没加载完毕呢');
				return false;
			};
			iframe.save();
			return false;
		},
		'okVal':'添加保存',
		'cancelVal':'取消',
		'cancel':function(){
			return true;
		}
	});
}
function collection_del(fid)
{
	$.dialog.confirm('确定要删除这个字段吗？删除后相应的采集数据也会被删除',function(){
		var url = "{url ctrl=plugin func=exec id=collection exec=field_del/}&fid="+fid;
		var rs = $.phpok.json(url);
		if(rs.status == 'ok'){
			$.phpok.reload();
			return false;
		}
		$.dialog.alert(rs.content);
		return false;
	})
}
</script>
<div class="layui-card">
	<div class="layui-card-header">
		<div class="layui-btn-group fr">
			<input type="button" value="添加字段" onclick="collection_add()" class="layui-btn layui-btn-sm" />
			<input type="button" value="关闭窗口" onclick="$.admin.close()" class="layui-btn layui-btn-sm layui-btn-danger" />
		</div>
	</div>
	<div class="layui-card-body">
		<table class="layui-table">
		<thead>
		<tr>
			<th>ID</th>
			<th>名称</th>
			<th>标识</th>
			<th>类型</th>
			<th>&nbsp;</th>
		</tr>
		</thead>
		<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
		<tr>
			<td class="center">{$value.id}</td>
			<td>{$value.title}</td>
			<td>{$value.identifier}</td>
			<td><!-- if $value.tags_type == 'var' -->变量<!-- else -->固定字串，值是：<span class="red">{$value.rules}</span><!-- /if --></td>
			<td>
				
				<div class="layui-btn-group">
					<input type="button" value="{lang编辑}" onclick="collection_edit('{$value.id}')" class="layui-btn layui-btn-sm" />
					<input type="button" value="{lang删除}" onclick="collection_del('{$value.id}')" class="layui-btn layui-btn-sm layui-btn-danger" />
				</div>
			</td>
		</tr>
		<!-- /loop -->
		</table>
	</div>
</div>
<!-- include tpl=foot -->